#!/usr/bin/python

import os

def commit(msg):
	git_cmd = 'git commit -a -m "{0}"'.format(msg)
	os.system(git_cmd)
	hg_cmd = 'hg commit -A -m "{0}"'.format(msg)
	os.system(hg_cmd)

def push():
	git_cmd = 'git push'
	os.system(git_cmd)
	hg_cmd = 'hg push'
	os.system(hg_cmd)

def pull():
	git_cmd = 'git fetch; git merge origin/master'
	os.system(git_cmd)
	hg_cmd = 'hg pull; hg up'
	os.system(hg_cmd)

cmd_table = {
	'commit': commit,
	'co': commit,
	'push': push,
	'pull': pull
}

def print_help():
	print("""python scm.py push
python scm.py co/commit "your message"
""")

def main(args):
	if len(args) > 1 and args[1] in cmd_table:
		cmd_table[args[1]](*args[2:])
	else:
		print_help()
if __name__ == '__main__':
	import sys
	main(sys.argv)

